package main

import "fmt"

type Usb interface {
	start(string)
	stop(string, string)
}

type Phone struct {
	Name string
}

func (p Phone) start(val string) {
	fmt.Println("start", val)
}

func (p Phone) stop(val1 string, val2 string) {
	fmt.Println("stop", val1, val2)
}

type Camera struct {
}

func (p *Camera) start(val string) {
	fmt.Println("start", val)
}

func (p *Camera) stop(val1 string, val2 string) {
	fmt.Println("stop", val1, val2)
}

type Computer struct {
}

func (c Computer) work(usb Usb) {
	if _, ok := usb.(Phone); ok {
		usb.start("启动")
	} else {
		usb.stop("立即", "停止")
	}
}

func main() {
	//var phone Usb = &Phone{Name: "华为"} //也能赋值
	var phone Usb = Phone{Name: "华为"}
	var camera Usb = &Camera{}
	var computer = Computer{}
	computer.work(phone)
	computer.work(camera)
	fmt.Println("-----------------------------------------------")
}
